package com.bi.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 数据宽表实体类
 * 
 * @author BI Platform Team
 * @since 1.0.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_wide_table")
public class WideTable implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 宽表ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 宽表名称
     */
    @TableField("name")
    private String name;

    /**
     * 显示名称
     */
    @TableField("display_name")
    private String displayName;

    /**
     * 宽表描述
     */
    @TableField("description")
    private String description;

    /**
     * 类型：在线/离线
     */
    @TableField("type")
    private WideTableType type;

    /**
     * 数据源配置
     */
    @TableField("data_source")
    private String dataSource;

    /**
     * Elasticsearch索引名称
     */
    @TableField("es_index_name")
    private String esIndexName;

    /**
     * 表配置信息
     */
    @TableField(value = "table_config", typeHandler = com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
    private Object tableConfig;

    /**
     * 状态
     */
    @TableField("status")
    private WideTableStatus status;

    /**
     * 创建人
     */
    @TableField("creator")
    private String creator;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 删除标记
     */
    @TableField("deleted")
    @TableLogic
    private Boolean deleted;

    /**
     * 宽表字段列表（非数据库字段）
     */
    @TableField(exist = false)
    private List<WideTableField> fields;

    /**
     * 数据总数（非数据库字段）
     */
    @TableField(exist = false)
    private Long dataCount;

    /**
     * 数据宽表类型枚举
     */
    public enum WideTableType {
        ONLINE("在线"),
        OFFLINE("离线");

        private final String description;

        WideTableType(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    /**
     * 数据宽表状态枚举
     */
    public enum WideTableStatus {
        ACTIVE("激活"),
        INACTIVE("未激活");

        private final String description;

        WideTableStatus(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
}